﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace InnovTech.Data.Behavior
{
    /// <summary>
    /// Describes the parameter of a behavior.
    /// </summary>
    public class BehaviorParameter : IBehaviorParameter
    {

        protected Dictionary<string, object> _paramDict;

        public BehaviorParameter()
        {
            _paramDict = new Dictionary<string, object>();
        }

        /// <summary>
        /// Gets all parameter names.
        /// </summary>
        /// <returns></returns>
        public List<string> GetParameterNames()
        {
            return _paramDict.Keys.ToList();
        }

        /// <summary>
        /// Gets the value of a parameter.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="paramName"></param>
        /// <returns></returns>
        public T GetParameterValue<T>(string paramName)
        {
            return (T)this[paramName];
        }

        /// <summary>
        /// Gets or sets the value of a parameter.
        /// </summary>
        /// <param name="paramName"></param>
        /// <returns></returns>
        public object this[string paramName]
        {
            get
            {
                return _paramDict[paramName];
            }
            set
            {
                _paramDict[paramName] = value;
            }
        }

        /// <summary>
        /// Checks whether contains a parameter.
        /// </summary>
        /// <param name="paramName"></param>
        /// <returns></returns>
        public bool Contains(string paramName)
        {
            return _paramDict.ContainsKey(paramName);
        }
    }
}
